<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>tl-ops-manage后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script src="../lib/layui/layui.js" v="layui" e="layui"></script>
    <link rel="stylesheet" type="text/css" href="../lib/layui/css/layui.css" />
</head>
<style>
    .layui-form-pane .layui-form-label {
        width: 160px;
    }
    .layui-form-pane .layui-input-block {
        margin-left: 160px;
    }
    input {
        color: darkorchid;
        font-weight: 700;
    }
    .tl-icon-font{
        border-radius: 23px;
        padding: 2px;
        font-size: 12px;
        background: burlywood;
        cursor: pointer;
    }
</style>
<body>

    <div class="layui-form layui-form-pane" lay-filter="tl-ops-web-waf-form" id="tl-ops-web-waf-form" style="padding: 20px 20px 0px 20px;">
        <div class="layui-form-item" style="display: none;">
            <label class="layui-form-label">错误类型KEY</label>
            <div class="layui-input-block">
                <input type="text" name="name" class="layui-input" placeholder="请输入错误类型KEY">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">错误名称</label>
            <div class="layui-input-block">
                <input type="text" name="zname" class="layui-input" placeholder="请输入错误名称">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">返回错误码</label>
            <div class="layui-input-block">
                <input type="number" name="code" class="layui-input" placeholder="请输入返回错误码"
                    id="tl-tips-code" onmouseleave="tl_mouse_leave_tips()"
                    onmouseenter="tl_mouse_enter_tips('tl-tips-code','错误码应在 200 ~ 599 之间')">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">返回格式</label>
            <div class="layui-input-block">
                <input type="text" name="content_type" class="layui-input"  placeholder="请输入返回格式"
                    id="tl-tips-content_type" onmouseleave="tl_mouse_leave_tips()"
                    onmouseenter="tl_mouse_enter_tips('tl-tips-content_type','出现此类型错误时，返回此内容格式，也就是content-type类型')">
            </div>
        </div>
        <div class="layui-form-item">
            <div  id="tl-tips-content" onmouseleave="tl_mouse_leave_tips()"
                onmouseenter="tl_mouse_enter_tips('tl-tips-content','出现此类型错误时，返回自定义内容')" >
                <textarea name="content" id="content"  class="layui-textarea" lay-verify="content"> </textarea>
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="tl-ops-web-waf-form-submit" id="tl-ops-web-waf-form-submit" value="确认">
        </div>
    </div>

    <script src="../lib/tl_ops_web_comm.js"></script>
    <script>
        layui.use(['table', 'form', 'layedit'], function () {
            window.form = layui.form;
            window.layedit = layui.layedit;
            let _lay_edit_index = layedit.build('content'); //建立编辑器

            window.tl_ops_web_waf_form_render = function(data){
                form.val("tl-ops-web-waf-form", Object.assign(form.val("tl-ops-web-waf-form"), data))
                form.render()
                layedit.setContent(_lay_edit_index, data.content, false);
            }
            
            form.verify({
                content : function (value, item) {
                    document.querySelector("#content").value = layedit.getText(_lay_edit_index);
                }
            });
        })
    </script>
</body>

</html>